<?php
class ApplicationModule_UserstatusAction extends KvfAction
{
  const UseLayout = false;
  protected $status;

  public function Process()
  {
    $this->status = array();
    $u = $this->_parent->USER;
    if($u)
    {
      $this->status["loggedIn"] = true;
      $this->status["username"] = $u->user_username;
      $this->status["hasSchedule"] = $u->HasExactAccess(ACCESS::display);
      $this->status["hasAdmin"] = $u->HasAccessFor(ACCESS::supervisor);
    }
    else
    {
      $this->status["loggedIn"] = false;
    }

    $this->status["urls"] = array(
                              "login" => KvfBase::$ROUTER->UrlFor("user","login",array(),array(), false),
                              "logout" => KvfBase::$ROUTER->UrlFor("user","logout",array(),array(), false),
                              "lostpass" => KvfBase::$ROUTER->UrlFor("user","lostpass",array(),array(), false),
                              "changepass" => KvfBase::$ROUTER->UrlFor("user","changepass",array(),array(), false),
                              "admin" => KvfBase::$ROUTER->UrlFor("admin","index",array(),array(), false),
                              "schedule" => KvfBase::$ROUTER->UrlFor("user","schedule",array(),array(), false)
                            );
  }

  public function Display()
  {
    SetMime("text/json-comment-filtered");
    print json_encode($this->status);
  }

}


?>
